package com.gary.shiro.service;

import com.gary.shiro.dao.UserRoleDAO;
import com.gary.shiro.po.UserRole;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @author peng_rui
 * @date 2022/3/26
 */
@Slf4j
@Service
public class UserRoleService {
    @Resource
    private UserRoleDAO userRoleDAO;

    public List<Long> queryRoleIdsByUserId(Long userId) {
        if (userId == null) {
            return null;
        }
        UserRole userRole = new UserRole().setUserId(userId);
        List<UserRole> select = userRoleDAO.select(userRole);
        return select.stream().map(UserRole::getId).collect(Collectors.toList());
    }
}
